package com.lanqiao.gxnushop.mapper;

import com.lanqiao.gxnushop.entity.Stores;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface StoresMapper {
    /**增加店铺
     * 需要传入的参数有：store（sellerId：卖家Id， name:店铺名, description:店铺描述,loginUrl:需要先进行文件上传, state:默认为0）*/
    @Insert("insert into stores(storeId,sellerId,name,description,zcsj,state) values (#{storeId},#{sellerId},#{name},#{description},now(),#{state})")
    boolean add (Stores stores);

    /**通过店铺编号：storeId 删除店铺*/
    @Delete("delete from stores where storeId = #{storeId}")
    boolean delete (String storeId);

    /**通过店铺编号：storeId 修改店铺信息*/
    @Update("update stores set name = #{name},description = #{description},state = #{state} where storeId = #{storeId}")
    boolean update (Stores stores);

    /**精确查找某个店铺   用于管理员店铺管理*/
    @Select("select * from stores where storeId = #{storeId}")
    Stores select (String storeId);

    /** 卖家名下的店铺*/
    @Select("select * from stores where sellerId = #{sellerId}")
    ArrayList<Stores> selectBySellerId (String sellerId);


    /**通过店名进行模糊查找*/
    @Select("select * from stores where name like concat('%',#{name},'%')")
    ArrayList<Stores> selectByName (String name);

    /**修改店铺de 图片*/
    @Update("update stores set logoUrl = #{logoUrl} where storeId = #{storeId}")
    boolean updateStoreImg(Stores stores);
}
